﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._19_中介者模式
{
    /// <summary>
    /// 用户类
    /// </summary>
    public class MsgUser
    {
        private readonly string _name;

        private readonly IChatRoomMediator _mediator;

        public MsgUser(string name, IChatRoomMediator mediator)
        {
            _name = name;
            _mediator = mediator;
        }

        public void Send(string message)
        {
            Console.WriteLine($"{_name} 发送: {message}");
            Thread.Sleep(1000);
            _mediator.SendMessage(message, this);
        }

        public void Receive(string message)
        {
            Console.WriteLine($"{_name} 接收: {message}");

        }


    }
}
